﻿using DefCore.Core;
using DefCore.Mapping;
using DefCore.Structures;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DefCore.Actors;

namespace DefCore
{
    public static partial class ConversionTools
    {
        public static Color WaringStateToColor(ActorAlertState state)
        {
            switch (state)
            {
                case ActorAlertState.LOW: return new Color(0x4C, 0xFF, 0x00, 0xFF);
                case ActorAlertState.MEDIUM: return new Color(0xFF, 0xD8, 0x00, 0xFF);
                case ActorAlertState.HIGH: return new Color(0xFF, 0x00, 0x00, 0xFF);

                default: return Color.Pink;
            }
        }

        public static BlueprintFrameAllowance FramesToFrameAllowance(StructureFrameEnum frames)
        {
            if (frames == 0)
                return 0;

            BlueprintFrameAllowance allowance = 0;
            if ((frames & StructureFrameEnum.CENTERFRAME) == StructureFrameEnum.CENTERFRAME)
                allowance = BlueprintFrameAllowance.CENTERFRAME;

            if ((frames ^ StructureFrameEnum.CENTERFRAME) != 0)
                allowance = allowance | BlueprintFrameAllowance.WALLFRAMES;

            return allowance;
        }
        public static StructureFrameEnum FrameAllowanceToFrames(BlueprintFrameAllowance frames)
        {
            if(frames == 0)
                return 0;

            StructureFrameEnum allowance = 0;
            if((frames & BlueprintFrameAllowance.CENTERFRAME) == BlueprintFrameAllowance.CENTERFRAME)
                allowance = StructureFrameEnum.CENTERFRAME;

            if ((frames & BlueprintFrameAllowance.WALLFRAMES) == BlueprintFrameAllowance.WALLFRAMES)
                allowance = allowance | StructureFrameEnum.NORTHFRAME | StructureFrameEnum.EASTFRAME | StructureFrameEnum.SOUTHFRAME | StructureFrameEnum.WESTFRAME;

            if (frames == BlueprintFrameAllowance.FULLFRAME)
                allowance = StructureFrameEnum.FULLFRAME;


            return allowance;
        }

        public static Vector2 PointToVect(Point point)
        {
            return new Vector2(point.X, point.Y);
        }
    }
}